

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>构建 Ceph &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="Ceph 镜像" href="../mirrors/" />
    <link rel="prev" title="克隆 Ceph 源码库" href="../clone-source/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">安装 Ceph</a></li>
          <li class="breadcrumb-item"><a href="../index_manual/">安装（手动）</a></li>
      <li class="breadcrumb-item active">构建 Ceph</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/install/build-ceph.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">安装 Ceph</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#id1">建议的方法</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id2">其他方法</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="../index_manual/">安装（手动）</a><ul class="current">
<li class="toctree-l4 current"><a class="reference internal" href="../index_manual/#id2">获取软件</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id3">安装软件</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id4">手动部署一套集群</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id5">升级软件</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#windows">Windows</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="ceph">
<h1>构建 Ceph<a class="headerlink" href="#ceph" title="Permalink to this heading"></a></h1>
<p>你可以下载 Ceph 源码并自行构建。首先，你得准备开发环境、编译
Ceph 、然后安装到用户区或者构建二进制包并安装。</p>
<section id="id1">
<h2>构建依赖<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>对照本段检查下你的 Linux/Unix 发行版是否满足这些依赖。</p>
</div>
<p>Ceph 的调试构建大概有 40 GB 大。如果你想在虚拟机（ VM ）里构建 Ceph ，
需要保证虚拟机的磁盘总空间大于 60 GB 。</p>
<p>还需要注意， Linux 的一些发行版（像 CentOS ）的默认安装会使用卷管理器（ LVM ）。
LVM 会在典型尺寸的虚拟磁盘上为操作系统保留一大块磁盘空间。</p>
<p>构建 Ceph 源码前，你得先安装几个库和工具：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">install</span><span class="o">-</span><span class="n">deps</span><span class="o">.</span><span class="n">sh</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>在某些支持 Google 内存剖析工具的发行版上，名字未必如此（如 <code class="docutils literal notranslate"><span class="pre">libgoogle-perftools4</span></code> ）。</p>
</div>
</section>
<section id="build-ceph">
<span id="id2"></span><h2>构建 Ceph<a class="headerlink" href="#build-ceph" title="Permalink to this heading"></a></h2>
<p>Ceph 是用 cmake 构建的，构建时，先进入刚克隆的 Ceph 源码库，然后执行下面的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">ceph</span>
<span class="o">./</span><span class="n">do_cmake</span><span class="o">.</span><span class="n">sh</span>
<span class="n">cd</span> <span class="n">build</span>
<span class="n">ninja</span>
</pre></div>
</div>
<p>参考<a class="reference external" href="../install-storage-cluster#installing-a-build">安装自构建软件</a>把构建好的软件安装到用户区，构建细节请看 <a class="reference external" href="https://github.com/ceph/ceph#building-ceph">Ceph README.md</a> 。</p>
</section>
<section id="id3">
<h2>构建 Ceph 安装包<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>要构建安装包，你必须克隆 <a class="reference external" href="../clone-source">Ceph</a> 源码库。
用 <code class="docutils literal notranslate"><span class="pre">dpkg-buildpackage</span></code> 基于最新代码为 Debian/Ubuntu 创建安装包；
用 <code class="docutils literal notranslate"><span class="pre">rpmbuild</span></code> 为 RPM 包管理器创建安装包。</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>在多核 CPU 上构建时，用参数 <code class="docutils literal notranslate"><span class="pre">-j</span></code> 、再加上核心数的 2 倍数，
例如在双核处理器上用 <code class="docutils literal notranslate"><span class="pre">-j4</span></code> 来加速构建。</p>
</div>
<section id="apt">
<h3>高级打包工具（ APT ）<a class="headerlink" href="#apt" title="Permalink to this heading"></a></h3>
<p>要为 Debian/Ubuntu 创建 <code class="docutils literal notranslate"><span class="pre">.deb</span></code> 安装包，先要克隆 Ceph 源码库、
安装好必要的 <a class="reference internal" href="#id1">构建依赖</a>和 <code class="docutils literal notranslate"><span class="pre">debhelper</span></code> 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">apt</span><span class="o">-</span><span class="n">get</span> <span class="n">install</span> <span class="n">debhelper</span>
</pre></div>
</div>
<p>装好 <code class="docutils literal notranslate"><span class="pre">debhelper</span></code> 之后就可以开始构建安装包了：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">dpkg</span><span class="o">-</span><span class="n">buildpackage</span>
</pre></div>
</div>
<p>在多核处理器上可以用 <code class="docutils literal notranslate"><span class="pre">-j</span></code> 加快构建速度。</p>
</section>
<section id="rpm">
<h3>RPM 包管理器<a class="headerlink" href="#rpm" title="Permalink to this heading"></a></h3>
<p>要创建 <code class="docutils literal notranslate"><span class="pre">.rpm</span></code> 包，先得克隆 <a class="reference external" href="../clone-source">Ceph</a> 源码库、
安装必要的<a class="reference internal" href="#id1">构建依赖</a>、安装好 <code class="docutils literal notranslate"><span class="pre">rpm-build</span></code> 和 <code class="docutils literal notranslate"><span class="pre">rpmdevtools</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">yum</span> <span class="n">install</span> <span class="n">rpm</span><span class="o">-</span><span class="n">build</span> <span class="n">rpmdevtools</span>
</pre></div>
</div>
<p>安装完这些工具后，设置 RPM 编译环境：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rpmdev</span><span class="o">-</span><span class="n">setuptree</span>
</pre></div>
</div>
<p>下载源码包，编译 RPM 时需要：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">wget</span> <span class="o">-</span><span class="n">P</span> <span class="o">~/</span><span class="n">rpmbuild</span><span class="o">/</span><span class="n">SOURCES</span><span class="o">/</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">download</span><span class="o">.</span><span class="n">ceph</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">tarballs</span><span class="o">/</span><span class="n">ceph</span><span class="o">-&lt;</span><span class="n">version</span><span class="o">&gt;.</span><span class="n">tar</span><span class="o">.</span><span class="n">bz2</span>
</pre></div>
</div>
<p>或者从欧洲镜像下载：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">wget</span> <span class="o">-</span><span class="n">P</span> <span class="o">~/</span><span class="n">rpmbuild</span><span class="o">/</span><span class="n">SOURCES</span><span class="o">/</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">eu</span><span class="o">.</span><span class="n">ceph</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">tarballs</span><span class="o">/</span><span class="n">ceph</span><span class="o">-&lt;</span><span class="n">version</span><span class="o">&gt;.</span><span class="n">tar</span><span class="o">.</span><span class="n">bz2</span>
</pre></div>
</div>
<p>提取规范文件：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tar</span> <span class="o">--</span><span class="n">strip</span><span class="o">-</span><span class="n">components</span><span class="o">=</span><span class="mi">1</span> <span class="o">-</span><span class="n">C</span> <span class="o">~/</span><span class="n">rpmbuild</span><span class="o">/</span><span class="n">SPECS</span><span class="o">/</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">anchored</span> <span class="o">-</span><span class="n">xvjf</span> <span class="o">~/</span><span class="n">rpmbuild</span><span class="o">/</span><span class="n">SOURCES</span><span class="o">/</span><span class="n">ceph</span><span class="o">-&lt;</span><span class="n">version</span><span class="o">&gt;.</span><span class="n">tar</span><span class="o">.</span><span class="n">bz2</span> <span class="s2">&quot;ceph.spec&quot;</span>
</pre></div>
</div>
<p>开始构建 RPM 包：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rpmbuild</span> <span class="o">-</span><span class="n">ba</span> <span class="o">~/</span><span class="n">rpmbuild</span><span class="o">/</span><span class="n">SPECS</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">spec</span>
</pre></div>
</div>
<p>在多核处理器上可以用 <code class="docutils literal notranslate"><span class="pre">-j</span></code> 加快构建速度。</p>
</section>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../clone-source/" class="btn btn-neutral float-left" title="克隆 Ceph 源码库" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../mirrors/" class="btn btn-neutral float-right" title="Ceph 镜像" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>